<?php
/**
 * Created by PhpStorm.
 * User: yiwan
 * Date: 2018/5/16
 * Time: 11:43
 */

ini_set('display_errors', 1);
error_reporting(-1);
require_once '/data/wwwroot/g_vendor/autoload.php';

use Biz\model\settlement\TransactionLog;
use Biz\model\settlement\Settlement;
use Biz\model\settlement\WillSettlement;
use Biz\model\settlement\HhzCost;
use Biz\model\settlement\HhzInCome;
use Biz\model\trade\OrderRefund;

$where = ['transaction_type' => [102, 202, 204, 308], 'status' => TransactionLog::STATUS_NORMAL];
$orderNos = TransactionLog::select('order_no', $where);
var_dump($orderNos);
$refundOrderList = OrderRefund::select(['order_no', 'goods_id', 'sku_id', 'refund_order_no'], ['order_no' => $orderNos, 'status' => OrderRefund::STATUS_COMPLETE]);
$refundList = [];
foreach ($refundOrderList as $row) {
    $data = ['refund_order_no' => $row['refund_order_no']];
    $where['order_no'] = $row['order_no'];
    $where['goods_id'] = $row['goods_id'];
    $where['sku_id'] = $row['sku_id'];
    TransactionLog::update($data, $where);
    Settlement::update($data, $where);
    WillSettlement::update($data, $where);
    HhzCost::update($data, $where);
    HhzInCome::update($data, $where);
}



